<!DOCTYPE html>
<html lang="en">

<head>
    <title>会员登陆页</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
<!--    <script src="../js/jquery-1.11.0.min.js"></script>-->
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
    <script type="text/javascript" src="../js/jquery-1.11.0.min.js"></script>
    <script src="../js/jquery-1.11.0.min.js"></script>
    <link rel="stylesheet" href="../css/style.css" type="text/css" media="all"/><!-- Style-CSS -->
    <link href="../css/font-awesome.css" rel="stylesheet">
    <script>
        //入口函数
        $(function () {
            $("#loginForm").submit(function () {
                var username = $("#username");
                var password = $("#password");
                var error = $("#error_info");
                if (username.value==""|| password.value=="") { //输入为空
                    error.text("用户名或密码不能为空！");
                    return false;
                } else {//不为空  ajax先判断
                    $.post("../user/doLogin.do", $(this).serialize(), function (data) {
                        if (data.errorType == 0) { //登录成功。
                            window.location.href="../static/index.html";
                            return false;
                        } else if (data.errorType == 1) {
                            error.text(data.errorInfo);
                        }
                    });
                }
                return false;
            });
            $("#test").click(function () {
                $.post("../user/doLogin.do", {"username": "test", "password": "root"}, function (data) {
                    alert(data.errorInfo);
                });
            });
        });
    </script>
</head>

<body>
<section class="w3l-form-36">
    <div class="form-36-mian section-gap">
        <div class="wrapper">
            <div class="form-inner-cont">
                <h3>会员登陆</h3>
                <span id="error_info"></span>
                <form id="loginForm" action="../user/login.do" method="post" class="signin-form">
                    <div class="form-input">
                        <span class="fa fa-envelope-o" aria-hidden="true"></span>
                        <input type="text" name="username" placeholder="请输入用户名..."/>
                    </div>
                    <div class="form-input">
                        <span class="fa fa-key" aria-hidden="true"></span>
                        <input type="password" name="password" placeholder="请输入密码..."/>
                    </div>
                    <div class="login-remember d-grid">
                        <button class="btn theme-button" type="submit">点击登录</button>
                    </div>
                </form>
                <p class="signup">还没注册? <a href="../static/regist.html" class="signuplink">立即去注册</a></p>
            </div>

            <!-- copyright -->
            <div class="copy-right">
                <p>Copyright &copy; 2021 Company swjd@Jiang All rights reserved</p>
            </div>
            <!-- //copyright -->
        </div>
    </div>
</section>
</body>

</html>
